<!DOCTYPE html>
<html lang="en-US">
  <head>
    <link href="/assets/index.css" rel="stylesheet" type="text/css" />
    <script crossorigin="anonymous" src="/test-harness.js"></script>
    <script crossorigin="anonymous" src="/test-page-object.js"></script>
    <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
  </head>
  <body>
    <main id="webchat"></main>
    <script>
      run(
        async function () {
          const { directLine, store } = testHelpers.createDirectLineEmulator();

          WebChat.renderWebChat({ directLine, store }, document.getElementById('webchat'));

          await pageConditions.uiConnected();

          await directLine.emulateIncomingActivity({
            attachments: [
              {
                contentType: 'video/*',
                contentUrl: 'https://youtu.be/rIJRFHDr1QE'
              }
            ],
            type: 'message'
          });

          await pageConditions.numActivitiesShown(1);

          await pageConditions.became('iframe has loaded', () => document.getElementsByTagName('iframe').length, 5000);

          const sandboxAttributeValue = document.getElementsByTagName('iframe')[0].getAttribute('sandbox');

          expect(sandboxAttributeValue).toBeTruthy();
        },
        // `axe-core` is accessing the IFRAME using `postMessage` and YouTube does not like it.
        // Nevertheless, we do not need to check accessibilty of YouTube.
        { skipCheckAccessibility: true }
      );
    </script>
  </body>
</html>
